/*
 * These files are distributed under the terms of the GNU GPLv2, the GNU General
 * Public version 2. See LICENSE.txt
 */
package fileCommodore.plugin.pathHopper;

import java.awt.event.*;

import org.apache.commons.vfs.*;

import fileCommodore.plugin.*;

public class PathHopperPlugin extends PanePlugin
{
	private PathHopper hopper = new PathHopper( 13 );
	private FileObject last = null;
	
	public PathHopperPlugin()
	{
		hopper.addMouseListener( new MouseAdapter()
		{
			@Override
			public void mouseClicked( MouseEvent e )
			{
				try
				{
					FileObject fo = hopper.getSelectedPath();
					changeTo( fo );
				}
				catch (FileSystemException e1)
				{
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
		} );
	}
	
	@Override
	public void handle( KeyEvent ev )
	{
		// TODO Auto-generated method stub
		
	}
	
	@Override
	public void selectionChanged()
	{
		FileObject fo = getSelection().getCurrent().getFileObject();
		if (null != fo && ( null == last || !fo.equals( last ) ))
		{
			hopper.setPath( fo );
		}
	}
	
	public PathHopper getHopper()
	{
		return hopper;
	}
}
